package io.geekidea.springboot.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.JsonNode;
import io.geekidea.springboot.handler.CustomJacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

@Getter
@Setter
@TableName("device")
@Schema(name = "Device", description = "设备表")
public class Device {

    @TableId(type = IdType.AUTO)
    @Schema(description = "设备ID")
    private Long id;

    @NotBlank(message = "设备名称不能为空")
    @Schema(description = "设备名称")
    private String name;

    @NotNull(message = "所属建筑ID不能为空")
    @Schema(description = "所属建筑ID")
    private Long buildingId;

    @Schema(description = "所属建筑名称")
    @TableField(exist = false)
    private String buildingName;

    @TableField(typeHandler = CustomJacksonTypeHandler.class)
    @Schema(description = "设备自定义属性")
    private JsonNode properties;

    @Schema(description = "创建时间")
    private LocalDateTime createdAt;

    @Schema(description = "更新时间")
    private LocalDateTime updatedAt;
}
